<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>品牌管理页</title>
    <style type="text/css">
        *{
            margin: 0 auto;
        }
        .tou{
            position: relative;
            height: 40px;
            width: 100%;
            background-color: green;
            margin-bottom: 20px;
            float: right;
            text-align: right;
            line-height: 40px;
            padding-right: 240px;
            color: white;
        }


        table{
            width: 100%;
            border-collapse: separate;
        }
        table tr{
            height: 60px;
        }

        table td{
            border: 2px solid lightslategrey;
            text-align: center;
            background-color: lightyellow;
        }
        #addBtn{
            width: 100px;
            height: 30px;
            border: 1px solid white;
            border-radius: 15px;
            background-color:gainsboro;
            margin-bottom: 20px;
            margin-left: 10px;
        }

        .zaixian{
            float: right;
            background-color: burlywood;
            width: 210px;
            height: 28px;
            text-align: center;
            margin-right: 10px;
            border-radius: 15px;
        }

        .zaixian span{
            color: black;
            font-weight: bold;
            font-size: 18px;
        }
        /*  HTML5已不支持   border="1" cellspacing="0" width="800" */
    </style>
</head>
<body>

<h3 class="tou">${LOGIN_USER.username},欢迎您!
    <a href="${ctx}/logout" style="text-decoration: none;color: white">[注销]</a>
    <h3 style="position: absolute;color: white;left:50px;line-height: 40px">欢迎访问品牌管理系统！</h3>
</h3>
<div class="zaixian">
    <span>当前在线用户数：${applicationScope.OnlineCount}</span>
</div>
<input type="button" value="新增" id="addBtn"><br>
<hr style="border: 1px solid lightslategrey">
<table class="a1">
    <tr>
        <th>序号</th>
        <th>品牌名称</th>
        <th>企业名称</th>
        <th>排序</th>
        <th>品牌介绍</th>
        <th>状态</th>
        <th>操作</th>

    </tr>


    <c:forEach items="${pageBean.data}" var="brand">

        <tr>
            <td>${brand.id}</td>
            <td>${brand.brandName}</td>
            <td>${brand.companyName}</td>
            <td>${brand.ordered}</td>
            <td>${brand.description}</td>
            <td>
                <c:if test="${brand.status ==1}">
                    启用
                </c:if>
                <c:if test="${brand.status ==0}">
                    禁用
                </c:if>
            </td>
            <td>
                <a href="${ctx}/toUpdate?id=${brand.id}">修改</a>
                <a href="${ctx}/delete?id=${brand.id}" onclick="if(confirm('确定删除?')==false)return false;">删除</a>
            </td>
        </tr>
    </c:forEach>
</table>
<div class="page-container">
    <jsp:include page="common/pageBar.jsp">
        <jsp:param name="url" value="/selectAll" />
    </jsp:include>
</div>

</body>

<script>
    function getContextPath() {
        var pathName = document.location.pathname;
        var index = pathName.substr(1).indexOf("/");
        var result = pathName.substr(0,index+1);
        return result;
    }

    let addBtn = document.querySelector("#addBtn")
    addBtn.addEventListener('click',function (){
        window.location.href = getContextPath()+"/addBrand.jsp"
    })
</script>

</html>
